<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>品牌管理</title>
    <script src="https://cdn.bootcss.com/vue/2.5.13/vue.js"></script>
    <style>
        #app {
            width: 600px;
            margin: 10px auto;
        }
        
        .tb {
            border-collapse: collapse;
            width: 100%;
        }
        
        th {
            background-color: #0094ff;
            color: white;
        }
        
        .tb td,
        .tb th {
            padding: 5px;
            border: 1px solid black;
            text-align: center;
        }
        
        .add {
            padding: 5px;
            border: 1px solid black;
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="add">
            编号:<input type="text" v-model=product.id> 品牌名称:
            <input type="text" v-model="product.name">
            <input type="button" value="添加" @click="addDate">
        </div>

        <div class="add">
            品牌名称:<input type="text" placeholder="请输入搜索条件">
        </div>

        <div>
            <table class="tb">
                <tr>
                    <th>编号</th>
                    <th>品牌名称</th>
                    <th>创立时间</th>
                    <th>操作</th>
                </tr>
                <tr v-for="item in list" :key="item.id">
                    <td>{{item.id}}</td>
                    <td>{{item.name}}</td>
                    <td>{{item.ctime}}</td>
                    <td>
                        <a href="javascript:void(0)">删除</a>
                    </td>
                </tr>

            </table>
        </div>
    </div>
</body>

</html>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            product: {
                id: 0,
                name: "",
                ctime: Date()
            },
            list: [{
                id: 1,
                name: '宝马',
                ctime: Date()
            }, {
                id: 2,
                name: '奔驰',
                ctime: Date()
            }]
        },
        methods: {
            addDate() {
                this.product.ctime = Date();
                this.list.push(this.product);
                this.product = {
                    id: 0,
                    name: "",
                    ctime: Date()
                };
            }
        }
    })
</script>